home *** CD-ROM | disk | FTP | other *** search
- Path: news.th-darmstadt.de!news!enno
- From: enno@inferenzsysteme.informatik.th-darmstadt.de (Enno Sandner)
- Newsgroups: comp.lang.c++
- Subject: Re: inherited classes / functions
- Date: 02 Feb 1996 19:35:38 GMT
- Organization: Fachbereich Informatik, TH Darmstadt
- Distribution: world
- Message-ID: <ENNO.96Feb2203538@kitz.inferenzsysteme.informatik.th-darmstadt.de>
- References: <Pine.A32.3.91.960202182844.45749A-100000@asterix.uni-muenster.de>
- NNTP-Posting-Host: kitz.intellektik.informatik.th-darmstadt.de
- In-reply-to: Gerhard Kutzelnigg's message of Fri, 2 Feb 1996 18:34:43 +0100
-
- In article <Pine.A32.3.91.960202182844.45749A-100000@asterix.uni-muenster.de> Gerhard Kutzelnigg <kutzeln@uni-muenster.de> writes:
-
- Hi All,
-
- when using inherited virtual functions, how can I simply call the
- "inherited" function without knowing the name of the parent class?
-
- -> While I am developing a graphical user interface, I sometimes need to
- "insert" a class in the class hierarchy, so I don't want to change all the
- "subclasses" code when "inserting" the new class. In Turbo Pascal there was
- the keyword "inherited" so I could call something like
- "inherited myfunction ();" but how can I resolve this expression in c++ ???
-
- This feature isn't supported in C++. However one can reduce the necessary
- modifications by declaring the super-class as a local type 'Super':
-
- class Base { ... f(); ... };
- class Der : public Base { // (1)
- typedef Base Super; // (2)
- public
- void f1() { ... Super :: f(); ... }
- void f2() { ... Super :: f(); ... }
- };
-
- When you insert a new class only (1)+(2) have to be changed.
-
- Enno
-